import React from 'react'
import { useSearchParams, useLocation } from 'react-router-dom'

export default function Detail() {
  // 跟useState的传参有点类似
  const [search, setSearch] = useSearchParams()

  const xx = useLocation()
  
  console.log("useLocation", xx)

  return (
    <div>
      <ul>
        <li>id: {search.get('id')}</li>
        <li>title: {search.get('title')}</li>
        <li>content: {search.get('content')}</li>
        <li>
          <button 
            onClick={()=>{setSearch('id=008&title=哈哈&content=嘻嘻')}}>
            点我更新一下收到的Search参数
          </button>
        </li>
      </ul>
    </div>
  )
}
